package game.leon.seawar.server.handler.impl;

import game.leon.engine.pattern.Fun;
import game.leon.seawar.server.handler.FunParam;
import game.leon.seawar.vo.BaseVO;
import game.leon.seawar.server.service.BattleService;
import game.leon.seawar.vo.Vo;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * User: bianpeng
 * Date: 12-1-4
 */
@Component
public class SessonCloseFun implements Fun<FunParam<Vo.EmptyVO>, BaseVO> {
    private Logger logger = Logger.getLogger(getClass());
    @Autowired
    private BattleService battleService;
    @Override
    public BaseVO exec(FunParam<Vo.EmptyVO> data) {
        logger.info("session closed");
        long userId = data.getSession().getUserId();
        // 登出, 不忘结束掉他的战斗
        battleService.removeBattle(userId);
        return null;
    }
}
